#include"../../inc/net/TcpServer.h"
#include"../../inc/net/Acceptor.h"
#include"../../inc/net/EventLoop.h"
#include<string>

using std::string;


namespace SC
{
    TcpServer::TcpServer(const string& ip, unsigned short port)
    : _acceptor(ip, port) ,_loop(_acceptor)
    {
    }

    void TcpServer::start()
    {
        _acceptor.Start();
        _loop.Loop();
    }

    void TcpServer::stop()
    {
        _loop.Unloop();
    }

    void TcpServer::setConnectionCB(const TcpConnectionCallBack& cb)
    {
        _loop.setConnectCB(std::move(cb));
    }

    void TcpServer::setMessageCB(const TcpConnectionCallBack& cb)
    {
        _loop.setMessageCB(std::move(cb));
    }

    void TcpServer::setCloseCB(const TcpConnectionCallBack& cb)
    {
        _loop.setCloseCB(std::move(cb));
    }
}